using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.WebPartPages;
using System.Collections;
//using ;

namespace ITTeamWorkspace.Features.Feature1
{
    /// <summary>
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// </summary>
    /// <remarks>
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// </remarks>

    [Guid("17496e9e-5140-4f97-8bfa-5f7a3abd7881")]
    public class Feature1EventReceiver : SPFeatureReceiver
    {
        // Uncomment the method below to handle the event raised after a feature has been activated.

        //public override void FeatureActivated(SPFeatureReceiverProperties properties)
        //{
        //}


        //public void PostProcessWebPartsOnPage(string pageName, SPWeb targetWeb)
        //{
        //    SPFile file = targetWeb.GetFile(pageName);
        //    if (file != null)
        //    {
        //        SPLimitedWebPartManager limitedWebPartManager = file.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

                
        //        using (IEnumerator enumerator = limitedWebPartManager.WebParts.GetEnumerator())
        //            {
                    

        //            DataFormWebPart part;
        //            bool flag;
        //            goto Label_009C;
        //        Label_001D:
        //            flag = false;
        //            DataFormWebPart part2 = part;
        //            string str = this.SubstituteTokens(part2.ParameterBindings);
        //            if (str.Equals(part2.ParameterBindings))
        //            {
        //                goto Label_0075;
        //            }
        //            goto Label_00D8;
        //        Label_004C:
        //            flag = true;
        //            part2.ListName =str;
        //        Label_0096:
        //            while (flag)
        //            {
        //                limitedWebPartManager.SaveChanges(part2);
        //                break;
        //            Label_0064:
        //                flag = true;
        //                part2.Xsl = (str);
        //                goto Label_010A;
        //            Label_0075:
        //                str = this.SubstituteTokens(part2.DataSourcesString);
        //                if (str.Equals(part2.DataSourcesString))
        //                {
        //                    goto Label_00E6;
        //                }
        //                goto Label_00AD;
        //            }
        //        Label_009C:
        //            if (enumerator.MoveNext())
        //            {
        //                goto Label_00BB;
        //            }
        //            return;
        //        Label_00AD:
        //            flag = true;
        //            part2.DataSourcesString =(str);
        //            goto Label_00E6;
        //        Label_00BB:
        //            part = (DataFormWebPart)enumerator.Current;
        //            if (part is DataFormWebPart)
        //            {
        //                goto Label_001D;
        //            }
        //            goto Label_009C;
        //        Label_00D8:
        //            flag = true;
        //            part2.ParameterBindings = (str);
        //            goto Label_0075;
        //        Label_00E6:
        //            str = this.SubstituteTokens(part2.Xsl);
        //            if (!str.Equals(part2.Xsl))
        //            {
        //                goto Label_0064;
        //            }
        //        Label_010A:
        //            if (part2.ListName == null)
        //            {
        //                goto Label_0096;
        //            }
        //            str = this.SubstituteTokens(part2.ListName);
        //            if (str.Equals(part2.ListName))
        //            {
        //                goto Label_0096;
        //            }
        //            goto Label_004C;
        //        }
        //    }
        //}


        //protected string SubstituteTokens(string inString)
        //{
        //    string str = "";
        //    int index = inString.IndexOf("%TSATOK:");
        //    int num2 = -1;
        //    int startIndex = 0;
        //Label_0018:
        //    if (index > -1)
        //    {
        //        num2 = inString.IndexOf("%", (int)(index + 1));
        //        if (num2 >= 0)
        //        {
        //            if ((index - startIndex) > 0)
        //            {
        //                str = str + inString.Substring(startIndex, index - startIndex);
        //            }
        //            string inToken = inString.Substring(index + "%TSATOK:".Length, (num2 - index) - "%TSATOK:".Length);
        //            //inToken = this.ProcessToken(inToken);
        //            str = str + inToken;
        //            startIndex = num2 + 1;
        //            num2 = -1;
        //            index = inString.IndexOf("%TSATOK:", startIndex);
        //            goto Label_0018;
        //        }
        //    }
        //    if (startIndex >= inString.Length)
        //    {
        //        return str;
        //    }
        //    return (str + inString.Substring(startIndex));
        //}

 

 


        // Uncomment the method below to handle the event raised before a feature is deactivated.

        //public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        //{
        //}


        // Uncomment the method below to handle the event raised after a feature has been installed.

        //public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        //{
        //}


        // Uncomment the method below to handle the event raised before a feature is uninstalled.

        //public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        //{
        //}

        // Uncomment the method below to handle the event raised when a feature is upgrading.

        //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
        //{
        //}
    }
}
